
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台</title>

    <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-datetimepicker.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-switch.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
</head>

<body>

<include file="Common/topNav" />

<div class="container-fluid">
    <div class="row">
        <include file="Common/leftMenu" />
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="cont-title clearfix">
                <div class="title">会议预约列表</div>
                <!--<div class="btn-group">
                    <button class="btn" type="button" id="add_space">添加</button>
                    <button class="btn" type="button" id="del_space">删除</button>
                </div>-->
            </div>
            <include file="search" />
            <div class="table-responsive">
                <table class="table table-striped table-hover" id="tableData">
                    <thead>
                    <tr>
                        <th>开始时间</th>
                        <th>时长</th>
                        <th>团队名称</th>
                        <th>会议室名称</th>
                        <th>费用（&yen;）</th>
                        <th>会议状态</th>
                        <th>审核状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <empty name="meetingOrderList">
                        <tr>
                            <td colspan="8">没有相关记录</td>
                        </tr>
                    </empty>
                    <foreach name="meetingOrderList" item="meetOrder">
                        <tr>
                            <td>{$meetOrder.start_time|date="Y-m-d H:i",###}</td>
                            <td>{$meetOrder.length}</td>
                            <td>{$meetOrder.team.team_name}</td>
                            <td>{$meetOrder.room.name}</td>
                            <td>{$meetOrder.cost|number_format=2}</td>
                            <td>
                                <if condition="$meetOrder.start_time gt $curTime">
                                    <span class="label label-success">未开始</span>
                                <elseif condition="$meetOrder.end_time lt $curTime"/>
                                    <span class="label label-primary">已结束</span>
                                <else/>
                                    <span class="label label-danger">进行中</span>
                                </if>
                            </td>
                            <td>
                                <if condition="$meetOrder.status eq 0">
                                    <span class="label label-warning">待审核</span>
                                <elseif condition="$meetOrder.status eq 1"/>
                                    <span class="label label-success">正常</span>
                                <else/>
                                    <span class="label label-danger" title="{$meetOrder.reason}">审核未通过</span>
                                </if>
                            </td>
                            <td>
                                <a thisId="{$meetOrder.id}" href="javascript:void(0);" class="meeting_edit">修改</a>
                                | <a thisId="{$meetOrder.id}" href="javascript:void(0);" class="meeting_del">删除</a>
                                <if condition="$meetOrder['status'] eq 0">
                                    | <a thisId="{$meetOrder.id}" href="javascript:void(0);" class="meeting_approve">审核</a>
                                </if>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
                <div class="page">
                    {$page}
                </div>
            </div>
        </div>
    </div>
</div>


<include file="Common/modalHtmls" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-switch.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript">
    $('#datetimepicker1').datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'ch',
        pickDate: true,
        pickTime: false,
        autoclose:true,
        minView:2,
        //pickerPosition:"bottom-left"
    });
    $('#datetimepicker2').datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'ch',
        pickDate: true,
        pickTime: false,
        autoclose:true,
        minView:2,
        //pickerPosition:"bottom-left"
    });
    $(function(){
        $("#tableData .meeting_edit").click(function(){
           meetingSpace(this);
        });
        $("#tableData .meeting_del").click(function(){
            delMeeting(this);
        });
        $("#tableData .meeting_approve").click(function () {
            approveMeeting(this);
        });
    });
    function meetingSpace(obj){
        var id = $(obj).attr("thisId");
        common.loading('正在加载...');
        common.htmlAjax("{:U('Admin/Space/Meeting/add')}", {id:id}, function (html) {
            common.closeLoading();
            $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
        });
    }

    function delMeeting(obj){
        common.confirm("提示","确认删除该预约吗？",function(){
            var id = $(obj).attr("thisId");
            var param = {id:id};
            $.ajax({
                url: "{:U('Admin/Space/Meeting/delete')}",
                type: "post",
                dataType: "json",
                data: param,
                success: function (data) {
                    if(data){
                        common.alert("提示","预约已成功删除!",function(){
                            common.reload();
                        });
                    }
                }
            });
        });
    }
    
    function approveMeeting(obj) {
        var id = $(obj).attr("thisId");
        common.loading('正在加载...');
        common.htmlAjax("{:U('Admin/Space/Meeting/approve')}", {id:id}, function (html) {
            common.closeLoading();
            if(common.isJsonString(html)){
                var error = JSON.parse(html);
                if (error.info){
                    common.alert("提示",error.info);
                }
                return;
            }
            $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
        });
    }
</script>
</body>
</html>
